﻿<%@ Page Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="PS_AbsenceRules.aspx.cs" Inherits="KPIS.GERP.GHRMS.APP.PS_AbsenceRules" %>
<%@ Import Namespace="KPIS.GERP.GHRMS.APP.Classes" %>
<%@ Register src="../Controls/EmployeeTypeCombo.ascx" tagname="EmployeeTypeCombo" tagprefix="uc1" %>
<%@ Register src="../Controls/user.ascx" tagname="user" tagprefix="uc2" %>

<asp:Content 
    ID="Content1" 
    runat="server" 
    contentplaceholderid="ContentPlaceHolder1">    
    <title>กำหนดหลักเกณฑ์การลา</title>
    <link href="../../Styles/CssClass.css" rel="stylesheet" type="text/css" />
    
    <style type="text/css">
        .rgGroupHeader td{
            font-size: 15px;
        }
    </style>
    <telerik:RadCodeBlock ID="RadCodeBlock2" runat="server">        
        <script type="text/javascript">
            function onTextChange(sender) {
                if (sender.get_value() == "") {
                    sender.set_text("");
                }
            }
                            
        </script>       
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="cmdFilter">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" 
                        LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" 
                        LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting> 
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" 
        Height="100%" Width="75px" Transparency="50">
        <table style="height: 100%; width: 100%" border="0">
            <tr>
                <td width="100%" align="center" valign="middle">
                    <img alt="Loading..." 
                        src="../Images/Buttons/loading.gif" 
                        style="border: 0px;" />
                </td>
            </tr>
        </table>
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <table id="tblContent" width="100%" >
        <tr id="rowFilter">
            <td>
                <div class="Background980V2" style="width: 980px; margin: 5px 0 0px 0;">
                    <table align="center" style="width: 100%; ">
                        <tbody>
                            <tr>
                                <td style="text-align: right; width:300px">ประเภทบุคลากร : </td>
                                <td style="width:300px">
                                    <telerik:RadComboBox ID="radCmbEmpType" Runat="server" DataTextField="Value" DataValueField="Key" Width="100%">
                                    </telerik:RadComboBox>
                                </td>
                                <td style="width:120px"><asp:Button ID="cmdFilter" runat="server" OnClick="cmdFilter_Click" Text="กรองข้อมูล" /></td>
                                <td>&nbsp;</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </td>
        </tr>
        <tr id="rowGrid">
            <td>
                <div class="Background980V2" style="width: 980px; margin: 5px 0 5px 0;">
                    <asp:Panel ID="Panel7" runat="server" ScrollBars="Auto" >
                        <table width="100%" border="0">
                            <tr>
                                <td class="tableHeader">
                                    <asp:Label ID="lblHeader" Text="เงื่อนไขการลา" runat="server" Font-Bold="True"></asp:Label>
                                    &nbsp;-
                                    <asp:Label ID="lblHeader0" runat="server" Font-Bold="True" Font-Names="Tahoma" Font-Size="small" ForeColor="#006699" Text="แยกตามประเภทการลา + ประเภทบุคลากร"></asp:Label>
                                    <telerik:RadTextBox ID="txtSearch0" runat="server" Visible="False">
                                    </telerik:RadTextBox>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <asp:Panel ID="Panel4" runat="server" ScrollBars="Auto" Width="980px">
                        <table width="100%" align="center" border="0">
                            <tr>
                                <td>
                                    <telerik:RadGrid ID="RadGrid1" runat="server"
                                        AllowAutomaticDeletes="True"
                                        AllowFilteringByColumn="True"
                                        AllowMultiRowEdit="True"
                                        AllowMultiRowSelection="True"
                                        AllowPaging="True"
                                        AllowSorting="True"
                                        AutoGenerateColumns="False"
                                        EnableAJAX="True"
                                        EnableAJAXLoadingTemplate="True"
                                        GridLines="None"
                                        OnItemCommand="RadGrid1_ItemCommand" Skin="Outlook"
                                        Width="100%" CellSpacing="0" PageSize="100" OnItemCreated="RadGrid1_ItemCreated">
                                        <MasterTableView AllowMultiColumnSorting="True"
                                            CellSpacing="-1"
                                            ClientDataKeyNames="Sequence"
                                            CommandItemDisplay="Top"
                                            DataKeyNames="Sequence"
                                            InsertItemPageIndexAction="ShowItemOnCurrentPage"
                                            NoMasterRecordsText="&lt; ไม่มีข้อมูล &gt;">
                                            <CommandItemTemplate>
                                                <table width="100%">
                                                    <tr>
                                                        <td>
                                                            <asp:LinkButton ID="cmdAddNew"
                                                                runat="server"
                                                                CausesValidation="False"
                                                                CommandName="InitInsert"
                                                                Visible="<%# !RadGrid1.MasterTableView.IsItemInserted && RadGrid1.EditIndexes.Count <= 0 %>">
                                <img style="border:0px;vertical-align:middle;" alt="" 
                                src="../Images/Buttons/AddRecord.gif" /> เพิ่มหลักเกณฑ์การลา</asp:LinkButton>
                                                            &nbsp;&nbsp;
                                                        </td>
                                                        <td align="right" width="100px"></td>
                                                    </tr>
                                                </table>
                                            </CommandItemTemplate>
                                            <CommandItemSettings ExportToPdfText="Export to PDF" />
                                            <RowIndicatorColumn>
                                                <HeaderStyle Width="20px" />
                                            </RowIndicatorColumn>
                                            <ExpandCollapseColumn>
                                                <HeaderStyle Width="20px" />
                                            </ExpandCollapseColumn>

                                            <Columns>
                                                <telerik:GridEditCommandColumn
                                                    ButtonType="ImageButton"
                                                    ItemStyle-Width="15">
                                                    <ItemStyle Width="15px" />
                                                </telerik:GridEditCommandColumn> 
                                                <telerik:GridButtonColumn
                                                    ButtonType="ImageButton"
                                                    CommandName="Delete"
                                                    ConfirmDialogType="RadWindow"
                                                    ConfirmText="ลบข้อมูลที่เลือก?"
                                                    ItemStyle-Width="15"
                                                    Text="คลิกเพื่อลบรายการนี้"
                                                    UniqueName="column1">
                                                    <ItemStyle Width="15px" />
                                                </telerik:GridButtonColumn>
                                                <telerik:GridBoundColumn
                                                    DataField="Sequence"
                                                    DataType="System.Int32"
                                                    Display="False"
                                                    HeaderText="Sequence"
                                                    ReadOnly="True"
                                                    UniqueName="Sequence"
                                                    Visible="False">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn
                                                    DataField="Sequence"
                                                    FilterControlWidth="100%"
                                                    DataType="System.Int32"
                                                    AutoPostBackOnFilter="true"
                                                    Display="True"
                                                    ShowFilterIcon="false"
                                                    HeaderText="#" 
                                                    UniqueName="SequenceDisplay"
                                                    Visible="True">
                                                    <HeaderStyle HorizontalAlign="Center" Width="32px" />
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </telerik:GridBoundColumn> 
                                                <telerik:GridBoundColumn
                                                    DataField="AbsenceType.Name"
                                                    HeaderStyle-HorizontalAlign="Center"
                                                    FilterControlWidth="100%"
                                                    ShowFilterIcon="false"
                                                    AutoPostBackOnFilter="true"
                                                    HeaderText="ประเภทการลา"
                                                    Visible="False"
                                                    UniqueName="AbsenceType.Name">
                                                    <HeaderStyle HorizontalAlign="Center" Width="180px" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridTemplateColumn
                                                    DataField="EmployeeType.Name"
                                                    HeaderStyle-HorizontalAlign="Center"
                                                    FilterControlWidth="100%"
                                                    ShowFilterIcon="false"
                                                    AutoPostBackOnFilter="true"
                                                    HeaderText="ประเภทบุคลากร"
                                                    UniqueName="cbEmployeeType">
                                                    <HeaderStyle HorizontalAlign="Center" Width="140px" />
                                                    <ItemTemplate>
                                                        <asp:LinkButton ToolTip='<%# Eval("AbsenceType.Name") %>'
                                                            ID="lbtEmpTypeNameForPopup" runat="server" 
                                                                        Text='<%# Eval("EmployeeType.Name") %>' 
                                                                        OnCommand="EmpTypeClick" 
                                                                        CommandArgument='<%# Eval("EmployeeType.Sequence") %>' />
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>
                                                <telerik:GridBoundColumn
                                                    DataField="QuotaDay"
                                                    HeaderStyle-HorizontalAlign="Center"
                                                    DataFormatString="{0:N0}"
                                                    FilterControlWidth="100%"
                                                    ShowFilterIcon="false"
                                                    AutoPostBackOnFilter="true"
                                                    HeaderText="ให้ลาได้ไม่เกิน(วัน)"
                                                    UniqueName="QuotaDay">
                                                    <HeaderStyle HorizontalAlign="Center" Width="70px" />
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn
                                                    DataField="QuotaDaySalary"
                                                    HeaderStyle-HorizontalAlign="Center"
                                                    HeaderText="ได้รับเงินเดือนระหว่างลาได้ไม่เกิน(วัน)"
                                                    FilterControlWidth="100%"
                                                    ShowFilterIcon="false"
                                                    AutoPostBackOnFilter="true"
                                                    DataFormatString="{0:N0}"
                                                    UniqueName="QuotaDaySalary">
                                                    <HeaderStyle HorizontalAlign="Center" Width="70px" />
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn
                                                    DataField="QuotaDayHalfSalary"
                                                    HeaderStyle-HorizontalAlign="Center"
                                                    HeaderText="ได้รับเงินเดือนครึ่งหนึ่งระหว่างลาได้ไม่เกิน(วัน)"
                                                    FilterControlWidth="100%"
                                                    ShowFilterIcon="false"
                                                    AutoPostBackOnFilter="true"
                                                    DataFormatString="{0:N0}"
                                                    UniqueName="QuotaDayHalfSalary">
                                                    <HeaderStyle HorizontalAlign="Center" Width="70px" />
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn
                                                    DataField="QuotaCount"
                                                    HeaderStyle-HorizontalAlign="Center"
                                                    FilterControlWidth="100%"
                                                    ShowFilterIcon="false"
                                                    AutoPostBackOnFilter="true"
                                                    HeaderText="จำนวนครั้งที่สามารถลาได้"
                                                    DataFormatString="{0:N0}"
                                                    UniqueName="QuotaCount">
                                                    <HeaderStyle HorizontalAlign="Center" Width="70px" />
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn
                                                    DataField="DayPerCount"
                                                    HeaderStyle-HorizontalAlign="Center"
                                                    FilterControlWidth="100%"
                                                    ShowFilterIcon="false"
                                                    AutoPostBackOnFilter="true"
                                                    HeaderText="จำนวนวันต่อครั้ง"
                                                    DataFormatString="{0:N0}"
                                                    UniqueName="DayPerCount">
                                                    <HeaderStyle HorizontalAlign="Center" Width="70px" />
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridTemplateColumn
                                                    HeaderText="ลาล่วงหน้า"
                                                    HeaderStyle-HorizontalAlign="Center"
                                                    FilterControlWidth="100%"
                                                    ShowFilterIcon="false"
                                                    AutoPostBackOnFilter="true"  
                                                    UniqueName="SendBefore">
                                                    <HeaderStyle HorizontalAlign="Center" Width="140px" />
                                                    <ItemTemplate>
                                                        <asp:Literal runat="server" 
                                                            Text='<%# new Main().ConvertNullInt(Eval("SendBefore")) > 0 
                                                        ? "<span style=\"color:blue\">ล่วงหน้าอย่างน้อย " + Eval("SendBefore") + " วัน</span>"
                                                        : new Main().ConvertNullInt(Eval("SendBefore")) < 0 
                                                            ? "<span style=\"color:orange\">ย้อนหลังไม่เกิน " + Math.Abs(new Main().ConvertNullInt(Eval("SendBefore"))??0) + " วัน</span>"
                                                            : "ไม่ใช้"%>'></asp:Literal>
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>
                                                <telerik:GridCheckBoxColumn
                                                    DataField="IncludeNonWorkingDay"
                                                    HeaderStyle-HorizontalAlign="Center"
                                                    ShowFilterIcon="False"
                                                    AutoPostBackOnFilter="True"
                                                    HeaderText="คิดวันลานับวันหยุด"
                                                    UniqueName="IncludeNonWorkingDay">
                                                    <HeaderStyle HorizontalAlign="Center" Width="60px" />
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </telerik:GridCheckBoxColumn>
                                                <telerik:GridTemplateColumn
                                                    HeaderText="เพศ"
                                                    HeaderStyle-HorizontalAlign="Center"
                                                    FilterControlWidth="100%"
                                                    ShowFilterIcon="false"
                                                    AutoPostBackOnFilter="true"  
                                                    UniqueName="GenderRule">
                                                    <HeaderStyle HorizontalAlign="Center" Width="60px" />
                                                    <ItemTemplate>
                                                        <asp:Literal ID="Literal1" runat="server" Text='เพศชาย' Visible='<%# new Main().ConvertNullInt(Eval("GenderSeq")) == 1 %>'/>
                                                        <asp:Literal ID="Literal2" runat="server" Text='เพศหญิง' Visible='<%# new Main().ConvertNullInt(Eval("GenderSeq")) == 2 %>' />
                                                        <asp:Literal ID="Literal3" runat="server" Text='-' Visible='<%# new Main().ConvertNullInt(Eval("GenderSeq")) == null %>' /> 
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>
                                                <telerik:GridBoundColumn
                                                    DataField="Remarks"
                                                    HeaderStyle-HorizontalAlign="Center"
                                                    FilterControlWidth="100%"
                                                    ShowFilterIcon="false"
                                                    AutoPostBackOnFilter="true"
                                                    HeaderText="หมายเหตุ"
                                                    UniqueName="Remarks">
                                                    <HeaderStyle HorizontalAlign="Center" />
                                                </telerik:GridBoundColumn>
                                            </Columns>
                                            <EditFormSettings EditFormType="WebUserControl"
                                                UserControlName="../UserControls/PS_AbsenceRules.ascx">
                                                <EditColumn UniqueName="EditCommandColumn1">
                                                </EditColumn>
                                            </EditFormSettings>
                                            <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="True" />
                                            <GroupByExpressions>
                                                <telerik:GridGroupByExpression>
                                                    <SelectFields>
                                                        <telerik:GridGroupByField FieldAlias="ประเภทการลา" FieldName="AbsenceType.Name" ></telerik:GridGroupByField>
                                                    </SelectFields>
                                                    <GroupByFields>
                                                        <telerik:GridGroupByField FieldName="AbsenceType.Name"  ></telerik:GridGroupByField>
                                                    </GroupByFields>
                                                </telerik:GridGroupByExpression> 
                                            </GroupByExpressions> 
                                        </MasterTableView>
                                        <ClientSettings AllowColumnHide="True"
                                            AllowColumnsReorder="True"
                                            EnableRowHoverStyle="True"
                                            ReorderColumnsOnClient="True">
                                            <Selecting AllowRowSelect="True" EnableDragToSelectRows="true" />
                                            <ClientEvents />
                                        </ClientSettings>
                                        <PagerStyle AlwaysVisible="True" FirstPageToolTip="หน้าแรก" LastPageText="หน้าสุดท้าย" LastPageToolTip="หน้าสุดท้าย" NextPagesToolTip="หน้าถัดไป" NextPageText="หน้าถัดไป" NextPageToolTip="หน้าถัดไป" PageButtonCount="100" PagerTextFormat="เปลี่ยนหน้า: {4} &amp;nbsp;หน้า &lt;strong&gt;{0}&lt;/strong&gt; จาก &lt;strong&gt;{1}&lt;/strong&gt;, items &lt;strong&gt;{2}&lt;/strong&gt; to &lt;strong&gt;{3}&lt;/strong&gt; of &lt;strong&gt;{5}&lt;/strong&gt;" PageSizeLabelText="จำนวนต่อหน้า:" PrevPagesToolTip="หน้าก่อน" PrevPageText="หน้าก่อน" PrevPageToolTip="หน้าก่อน" />
                                        <StatusBarSettings LoadingText="ดึงข้อมูล..." ReadyText="พร้อม" />
                                        <FilterMenu EnableImageSprites="False">
                                        </FilterMenu>
                                        <GroupingSettings >
                                            
                                        </GroupingSettings>
                                    </telerik:RadGrid>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </div>
            </td>
        </tr>
    </table>
    <telerik:RadWindow ID="RadWindow1" runat="server" NavigateUrl="400px" Width="500px" ReloadOnShow="True" SkinID="Outlook" Skin="Outlook" />
    <script type="text/javascript">
        function popupWindow1(empTypeSeq) { 
            var oWnd = $find("<%=RadWindow1.ClientID%>");
            oWnd.setUrl("PS_AbsenceRules.Popup.aspx?EmpTypeSeq=" + empTypeSeq);
            oWnd.show();
        }
    </script>
    </asp:Content>
